A collection of functions used by the UKCEH Edinburgh Spatial Data Team
Calibrated EMEP4UK ammonia concentrations 3-year mean (2019 - 2021)
# Return calibrated EMEP4UK ammonia concentrations (2019 - 2021)
# aggregate to 3 year mean
r_nh3_conc_19_21 <- conc_nh3_r(yrs = 2019:2021) %>% app(., mean, na.rm = T)
crs(r_nh3_conc_19_21) <- "EPSG:27700"
## project to 3857
r_conc_19_21_3857 <- project(r_nh3_conc_19_21, "EPSG:3857", res = 1000)
cols <- c("#9ce4ff","#fbff87","#ffa754","#ff5754","#b36bff")
brks <- c(0,1,2,3,4,99)
labs <- c("0 - 1","> 1 - 2","> 2 - 3","> 3 - 4","> 4")
pal <- colorBin(palette = cols,
bins = brks,
domain = values(r_conc_19_21_3857),
na.color = "transparent")
leaflet() %>%
addProviderTiles(providers$Esri.WorldGrayCanvas) %>%
addRasterImage(x = r_conc_19_21_3857, colors = pal, project = F) %>%
addLegend(colors = cols,
labels = labs, values = values(r_conc_19_21_3857))Filter UK designated sites
# Return site using a site ID
sf <- getSITE(ste_type = "SSSI", id = "1")
# Search for the correct site
sf <- getSITE(ste_type = "SSSI",grep_txt = "bog")
# Return sites by country
sac_4326 <- getSITE(ste_typ = "SAC",country = "Northern Ireland") %>%
st_transform(.,4326)
spa_4326 <- getSITE(ste_typ = "SPA",country = "Northern Ireland") %>%
st_transform(.,4326)
leaflet() %>%
addProviderTiles(providers$Esri.WorldGrayCanvas) %>%
addPolygons(data = sac_4326, color = "red", fillOpacity = 0.3,
weight = 1) %>%
addPolygons(data = spa_4326, color = "blue", fillOpacity = 0.3,
weight = 1) %>%
addLegend(colors = c("red","blue"), labels = c("SAC","SPA"))Filter UK SACs to return a boundary for Ballynahone Bog SAC (Site ID = ‘UK0016599’)
# Return site using a site ID
sf <- getSAC(id = "UK0016599")
# Search for the correct site
sf <- getSAC(grep_txt = "Bal")
# Return English SACs
sf <- getSAC(country = "England")
# Return site using a site name and add to Leaflet map
sf_4326 <- getSAC(grep_txt = "Ballynahone Bog") %>%
st_transform(.,4326)
leaflet() %>%
addProviderTiles(providers$Esri.WorldGrayCanvas) %>%
addPolygons(data = sf_4326, color = "red", fillOpacity = 0.3,
weight = 1)Filter UK SPAs to return a boundary for Solent and Dorset Coast SPA (Site ID = ‘UK9020330’)
# Return site using a site ID
sf <- getSPA(id = "UK9020330")
# Search for the correct site
sf <- getSPA(grep_txt = "Solen")
# Return English SPAs
sf <- getSPA(country = "England")
# Return site using a site name and add to Leaflet map
sf_4326 <- getSPA(grep_txt = "Solent and Dorset Coast") %>%
st_transform(.,4326)
leaflet() %>%
addProviderTiles(providers$Esri.WorldGrayCanvas) %>%
addPolygons(data = sf_4326, color = "red", fillOpacity = 0.3,
weight = 1)Filter UK SSSI/ASSI to return a boundary for A’ Mhoine SSSI (Site ID = ‘1’)
# Return site using a site ID
sf <- getSSSI(id = "1")
# Search for the correct site
sf <- getSSSI(grep_txt = "A'")
# Return English SSSIs
sf <- getSSSI(country = "England")
# Return site using a site name and add to Leaflet map
sf_4326 <- getSSSI(grep_txt = "A' Mhoine") %>%
st_transform(.,4326)
leaflet() %>%
addProviderTiles(providers$Esri.WorldGrayCanvas) %>%
addPolygons(data = sf_4326, color = "red", fillOpacity = 0.3,
weight = 1)Estimate cell coverage of sf object (Ballynahone Bog SAC)
# Return site using a site ID
sf_bally <- getSITE(ste_type = "SAC",id = "UK0016599")
# estimate cell coverage at 100 x 100 m
r <- cll_cvr_sf(sf = sf_bally, res = 100, prcsn = 25)
# check area matches sf object
# multiply total by res^2 to go from prop of grd sq to m2
r_tot <- (global(r,"sum")$sum * 100^2)
sf_tot <- st_area(sf_bally) %>% as.numeric()
# difference in m2
r_tot - sf_tot[1] -378
# improve prscn to reduce difference in area
r <- cll_cvr_sf(sf = sf_bally, res = 100, prcsn = 2)
r_tot <- (global(r,"sum")$sum * 100^2)
sf_tot <- st_area(sf_bally) %>% as.numeric()
# difference in m2
r_tot - sf_tot[1] -6.73
Return a table showing 1 km x 1 km grid of Ballynahone Bog SAC and Walton Moss SAC
dt <- cll_cvr_tbl(ste_type = "SAC",id = c("UK0016599","UK0030093"),prcsn = 25,res = 1000,as_dt = F)
## improve accuracy by lowering prcsn to 2m
dt <- cll_cvr_tbl(ste_type = "SAC",id = c("UK0016599","UK0030093"),prcsn = 2,res = 1000,as_dt = F)
head(dt,10)| x | y | SITECODE | SITENAME | PROP | GRID_RES_m | RASTER_AREA_HA | SHP_AREA_AREA_HA | DIFF_HA | DIFF_PCT |
|---|---|---|---|---|---|---|---|---|---|
| 98500 | 558500 | UK0016599 | Ballynahone Bog | 0.011 | 2 | 244 | 244 | -0.001 | 0 |
| 99500 | 558500 | UK0016599 | Ballynahone Bog | 0.208 | 2 | 244 | 244 | -0.001 | 0 |
| 100500 | 558500 | UK0016599 | Ballynahone Bog | 0.167 | 2 | 244 | 244 | -0.001 | 0 |
| 101500 | 558500 | UK0016599 | Ballynahone Bog | 0.023 | 2 | 244 | 244 | -0.001 | 0 |
| 98500 | 557500 | UK0016599 | Ballynahone Bog | 0.000 | 2 | 244 | 244 | -0.001 | 0 |
| 99500 | 557500 | UK0016599 | Ballynahone Bog | 0.479 | 2 | 244 | 244 | -0.001 | 0 |
| 100500 | 557500 | UK0016599 | Ballynahone Bog | 0.917 | 2 | 244 | 244 | -0.001 | 0 |
| 101500 | 557500 | UK0016599 | Ballynahone Bog | 0.377 | 2 | 244 | 244 | -0.001 | 0 |
| 98500 | 556500 | UK0016599 | Ballynahone Bog | 0.000 | 2 | 244 | 244 | -0.001 | 0 |
| 99500 | 556500 | UK0016599 | Ballynahone Bog | 0.000 | 2 | 244 | 244 | -0.001 | 0 |
Return SAC site description for Epping Forest SAC
v <- sac_description(id = "UK0012720")
paste0(v, collapse = "\n\n - ") %>% paste0("- ",.) %>% cat(., sep = "")Inland water bodies (Standing water, Running water) (6%)
Bogs, Marshes, Water fringed vegetation, Fens (0.2%)
Heath, Scrub, Maquis and Garrigue, Phygrana (3.8%)
Dry grassland, Steppes (20%)
Broad-leaved deciduous woodland (70%)
Return SAC annex I and II features for Epping Forest SAC
| FeatureType | PrimaryFeature | Description |
|---|---|---|
| Annex I | TRUE | 9120 Atlantic acidophilous beech forests with Ilex and sometimes also Taxus in the shrublayer (Quercion robori-petraeae or Ilici-Fagenion) Epping Forest represents Atlantic acidophilous beech forests in the north-eastern part of the habitat’s UK range. Although the epiphytes at this site have declined, largely as a result of air pollution, it remains important for a range of rare species, including the moss Zygodon forsteri. The long history of pollarding, and resultant large number of veteran trees, ensures that the site is also rich in fungi and dead-wood invertebrates. |
| Annex I | FALSE | 4010 Northern Atlantic wet heaths with Erica tetralix |
| Annex I | FALSE | 4030 European dry heaths |
| Annex II | TRUE | 1083 Stag beetle Lucanus cervus Epping Forest is a large woodland area in which records of stag beetle Lucanus cervus are widespread and frequent; the site straddles the Essex and east London population centres. Epping Forest is a very important site for fauna associated with decaying timber, and supports many Red Data Book and Nationally Scarce invertebrate species. |
Return area weighted ammonia concentrations for Ballynahone Bog
## Return latest 3 year mean (2019 - 2021)
dt <- ste_nh3_concs(ste_type = "SAC",id = "UK0016599",as_dt = T, prcsn = 1)
dt| SITECODE | SITENAME | Year | mean_nh3_conc | min_nh3_conc | max_nh3_conc | DIFF_HA |
|---|---|---|---|---|---|---|
| UK0016599 | Ballynahone Bog | 2019 - 2021 | 2.49 | 2.13 | 3.13 | 0 |
## Return annual estimates for 2002 - 2021
dt <- ste_nh3_concs(ste_type = "SAC",id = c("UK0016599"),
yrs = 2002:2021, agr_yrs = F,as_dt = T, prcsn = 5)
p <- ggplot()
p <- p + geom_point(data = dt, aes(x = Year, y = mean_nh3_conc, color = SITENAME),
size = 2)
p <- p + geom_line(data = dt, aes(x = Year, y = mean_nh3_conc, color = SITENAME),
linewidth = 0.5)
p <- p + geom_errorbar(data = dt, aes(x = Year, ymin = min_nh3_conc, ymax = max_nh3_conc,
color = SITENAME),
alpha = 0.6)
p + ylab(bquote("Ammonia Concentration"~"("*mu*g~NH[3]~m^-3*")"))dt <- ste_nh3_concs(ste_type = "SAC",id = c("UK0016599","UK0030093","UK0012720"),
yrs = 2002:2021, agr_yrs = F,as_dt = T, prcsn = 5)
p <- ggplot()
p <- p + geom_point(data = dt, aes(x = Year, y = mean_nh3_conc, color = SITENAME),
size = 2)
p <- p + geom_line(data = dt, aes(x = Year, y = mean_nh3_conc, color = SITENAME),
linewidth = 0.5)
p + ylab(bquote("Ammonia Concentration"~"("*mu*g~NH[3]~m^-3*")")) Return area weighted ammonia concentrations for Ballynahone Bog.
The following information are returned for the 1ug and 3ug critical levels:
Designation weighted indicator (DW) - shows the proportion of sites with exceedance, giving the same weight to each designated site, regardless of size. The rationale is that the designation of each site is of equal importance, and that it is equally relevant to protect smaller nature areas in the UK countryside. The approach recognises the fact that larger sites tend to be located in more remote (cleaner) locations, and that this indicator most closely matches to the assessment of ‘site integrity’.
Area weighted indicator (AW) - shows the overall area of sites with exceedance across all or part of their area, i.e. exceedance is estimated to occur in at least part of the site. The AWI implicitly assumes that the value associated with nature conservation is directly proportional to site area, while making the link to whether the integrity of each site is compromised by exceedance in any part of the site. However, for very large sites, the risk to designated features may be relatively small if only a small corner exceeds CL/CLE, and in these cases the AWI-2 may be a more suitable indicator.
Area weighted indicator 2 (AW2) - shows the actual exceeded areas within protected sites. The AWI-2 needs to be considered in combination with AWI, as the designated habitats and species in any protected site may or may not be located in the areas exceeded within sites. This indicator cannot quantify whether the designated features of a site would be protected or not, but shows of the % area of sites that are predicted to be below the CLe/CL. The DWI and the AWI, on the other hand, are more precautionary, in that they assume a site may be considered at risk when exceedance occurs in part of its area. Potential improvements from the tested mitigation scenarios can be seen by comparing both AWI and AWI-2 between scenarios, rather than looking at them in isolation.
## Return latest 3 year mean (2019 - 2021)
dt <- ste_cle_status(ste_type = "SAC",id = "UK0016599",as_dt = T, prcsn = 1)
dt| Year | SITECODE | SITENAME | AREA_HA | mean_nh3_conc | min_nh3_conc | max_nh3_conc | DIFF_HA | DW_1ug | AW_1ug | AW2_1ug | DW_3ug | AW_3ug | AW2_3ug |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2019 - 2021 | UK0016599 | Ballynahone Bog | 244 | 2.49 | 2.43 | 2.57 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
## Return annual estimates for 2002 - 2021
dt <- ste_cle_status(ste_type = "SAC",id = "UK0016599",yrs = 2002:2021, agr_yrs = F,as_dt = T, prcsn = 1)
dt| Year | SITECODE | SITENAME | AREA_HA | mean_nh3_conc | min_nh3_conc | max_nh3_conc | DIFF_HA | DW_1ug | AW_1ug | AW2_1ug | DW_3ug | AW_3ug | AW2_3ug |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 | UK0016599 | Ballynahone Bog | 244 | 2.23 | 2.14 | 2.33 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2003 | UK0016599 | Ballynahone Bog | 244 | 2.46 | 2.39 | 2.54 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2004 | UK0016599 | Ballynahone Bog | 244 | 1.97 | 1.88 | 2.06 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2005 | UK0016599 | Ballynahone Bog | 244 | 2.15 | 2.07 | 2.23 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2006 | UK0016599 | Ballynahone Bog | 244 | 2.41 | 2.33 | 2.50 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2007 | UK0016599 | Ballynahone Bog | 244 | 2.31 | 2.24 | 2.40 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2008 | UK0016599 | Ballynahone Bog | 244 | 1.98 | 1.93 | 2.06 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2009 | UK0016599 | Ballynahone Bog | 244 | 2.27 | 2.17 | 2.36 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2010 | UK0016599 | Ballynahone Bog | 244 | 2.40 | 2.31 | 2.50 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2011 | UK0016599 | Ballynahone Bog | 244 | 2.62 | 2.54 | 2.72 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2012 | UK0016599 | Ballynahone Bog | 244 | 2.08 | 2.03 | 2.15 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2013 | UK0016599 | Ballynahone Bog | 244 | 2.17 | 2.11 | 2.25 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2014 | UK0016599 | Ballynahone Bog | 244 | 2.20 | 2.14 | 2.28 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2015 | UK0016599 | Ballynahone Bog | 244 | 2.41 | 2.33 | 2.50 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2016 | UK0016599 | Ballynahone Bog | 244 | 2.43 | 2.36 | 2.51 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2017 | UK0016599 | Ballynahone Bog | 244 | 2.22 | 2.12 | 2.31 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2018 | UK0016599 | Ballynahone Bog | 244 | 2.87 | 2.79 | 2.96 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2019 | UK0016599 | Ballynahone Bog | 244 | 3.03 | 2.95 | 3.13 | 0 | 1 | 244 | 244 | 1 | 244 | 196 |
| 2020 | UK0016599 | Ballynahone Bog | 244 | 2.26 | 2.21 | 2.32 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
| 2021 | UK0016599 | Ballynahone Bog | 244 | 2.19 | 2.13 | 2.25 | 0 | 1 | 244 | 244 | 0 | 0 | 0 |
Return 2018 source attribution estimates
## Return source attribution for Ballynahone Bog SAC
dt <- ste_srce_attr(ste_type = "SAC",id = "UK0016599",as_dt = T, prcsn = 25)
# select top 3 sources of N dep.
dt[Dep_typ == "Low-growing semi-natural veg",] %>%
.[,.(kg_ha = sum(kg_ha)), by = FOOTPRINT_NAME] %>%
.[order(-kg_ha),] %>%
.[1:3,]| FOOTPRINT_NAME | kg_ha |
|---|---|
| Livestock (Northern Ireland) | 9.942 |
| Rep. of Ireland NHx sources | 1.487 |
| Other agriculture (Northern Ireland) | 0.668 |
Pie chart of 2018 source attribution estimates
## Return source attribution for Ballynahone Bog SAC
p <- ggpl_srce_attr(ste_type = "SAC",
id = "UK0016599",
dep_typ = "Woodland",
sep_wet_dry = F,
sep_nox_nhx = F,
txt_size = 10,
prcsn = 1)
p## Return source attribution for Ballynahone Bog SAC for wet/dry, nox/nhx
p <- ggpl_srce_attr(ste_type = "SAC",
id = "UK0016599",
dep_typ = "Woodland",
sep_wet_dry = T,
sep_nox_nhx = T,
txt_size = 10,
prcsn = 1)
p